# dataclass 是类在实例化过程中（调用__init__方法时，给属性赋值）自动传参和自动校验的工具类
from dataclasses import dataclass


@dataclass
class CaseInfo:
    # 必填
    feature: str
    story: str
    title: str
    request: dict
    validate: dict
    # 选填
    extract: dict = None
    parametrize: list = None


def verify_yaml(case: dict, yaml_name: str):
    try:
        new_case = CaseInfo(**case)
        return new_case
    except Exception:
        raise Exception(f"{yaml_name}: Yaml用例不符合框架规则！\n")
